package com.its.common.net.client.config;

import io.netty.buffer.ByteBuf;

/**
 * @Author xiaxp
 * @Date 9/14/22 14:55
 * @Description
 */
public abstract class BaseHeartbeatDefine implements HeartbeatDetectorDefine {

    protected boolean active;
    protected boolean printSendLog;
    protected int heartbeatInterval;

    /**
     * @param heartbeatInterval 心跳间隔，单位秒
     * @param printSendLog 打印心跳包发送日志
     */
    public BaseHeartbeatDefine(int heartbeatInterval, boolean printSendLog) {
        this.active = Boolean.TRUE;
        this.heartbeatInterval = heartbeatInterval;
        this.printSendLog = printSendLog;
    }

    @Override
    public boolean active() {
        return this.active;
    }

    @Override
    public int heartbeatInterval() {
        return this.heartbeatInterval;
    }

    @Override
    public boolean printHeartbeatSendLog() {
        return this.printSendLog;
    }

    /**
     * 自定义生成心跳包
     * @return 心跳包
     */
    @Override
    public abstract ByteBuf generateHeartbeatPacket();
}
